package com.atguigu.juc.study.chapter08.cas;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @author : leimingchao
 * @date Date : 2022年06月14日 21:34
 */
public class AtomicReferenceDemo {

    public static void main(String[] args) {

        AtomicReference<User> atomicReference = new AtomicReference<>();

        User z3 = new User("z3", 22);
        User li4 = new User("li4", 28);

        atomicReference.set(z3);

        System.out.println(atomicReference.compareAndSet(z3, li4) + "\t" + atomicReference.get());
        System.out.println(atomicReference.compareAndSet(z3, li4) + "\t" + atomicReference.get());
    }
}
